//
//  WH_ShareDetailVC.m
//  App_6.23
//
//  Created by wanghao on 16/7/28.
//  Copyright © 2016年 wanghao. All rights reserved.
//

#import "WH_ShareDetailVC.h"
#import "WH_Home.h"
#import "WH_NewDetailViewController.h"

@interface WH_ShareDetailVC ()

@property (nonatomic, strong) UIScrollView *bigScroll;

@end

@implementation WH_ShareDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"晒单详情";
    self.bigScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.bigScroll.pagingEnabled = YES;
    self.bigScroll.bounces = NO;
    self.bigScroll.showsVerticalScrollIndicator = NO;

    [self.view addSubview:_bigScroll];
    [self createDid];
    [self createSubViews:_detailModel.show_image_array];
}

-(void)createDid{
    
    
    UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, SCREEN_WIDTH/2, 20)];
    nameL.text = _detailModel.user_name;
    nameL.textColor = [UIColor blueColor];
    [self.bigScroll addSubview:nameL];
    
    UILabel *orderTimeL = [[UILabel alloc] initWithFrame:CGRectMake(nameL.frame.size.width + nameL.frame.origin.x, nameL.frame.origin.y,SCREEN_WIDTH - nameL.frame.origin.x*2 - nameL.frame.size.width, nameL.frame.size.height)];
    orderTimeL.textAlignment = NSTextAlignmentRight;
    orderTimeL.font = [UIFont systemFontOfSize:14.f];
    orderTimeL.text = _detailModel.show_time;
    [self.bigScroll addSubview:orderTimeL];
    
    UIView *bigV = [[UIView alloc] initWithFrame:CGRectMake(10, 50, SCREEN_WIDTH - 10*2, 140)];
    bigV.backgroundColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1];
    [self.bigScroll addSubview:bigV];
    
   // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushTodetailVC)];
    //[bigV addGestureRecognizer:tap];
    
    NSArray *modelArr = [NSArray arrayWithObjects:_detailModel.product_name, _detailModel.product_period_no, _detailModel.order_count, _detailModel.jiang_number, _detailModel.product_period_time, nil];
    NSArray *labelArr = [NSArray arrayWithObjects:@"获得商品 :", @"参与期号 :", @"本期参与 :", @"幸运号码 :", @"揭晓时间 :", nil];
    for (int i = 0; i < labelArr.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 10 + (20+5)*i, bigV.frame.size.width - 10, 20)];
        label.font = [UIFont systemFontOfSize:13.f];
        label.tag = 1000 + i;
        label.text = [NSString stringWithFormat:@"%@%@",labelArr[i], modelArr[i]];
        label.textColor = [UIColor lightGrayColor];
        [bigV addSubview:label];
    }
    
    
}
- (void)createSubViews:(NSMutableArray *)images{
    
    UILabel *contentL = [[UILabel alloc] init];
    contentL.text = _detailModel.show_content;
    contentL.font = [UIFont systemFontOfSize:15.f];
    [self.bigScroll addSubview:contentL];

    CGSize labSize = [WH_AppTools labelRectWithSize:CGSizeMake(SCREEN_WIDTH - 10*2, MAXFLOAT) LabelText:_detailModel.show_content Font:[UIFont systemFontOfSize:15.f]];
    contentL.frame = CGRectMake(10, 200, SCREEN_WIDTH - 10*2, labSize.height);
    
    for (int i = 0; i < images.count; i++) {
        
        UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10, labSize.height + 200 + i*(400 + 10)+10, SCREEN_WIDTH - 10*2, 400)];
        
        //第三方图片赋值
        [imgV sd_setImageWithURL:[NSURL URLWithString:images[i]] placeholderImage:PLACEHOLDER_CELL_SAME];
        [self.bigScroll addSubview:imgV];
    }
    
    self.bigScroll.contentSize = CGSizeMake(0,labSize.height + 220 + (400 +10)*images.count);

}
-(void)pushTodetailVC{
    
    WH_NewDetailViewController *newDetail = [[WH_NewDetailViewController alloc] init];
    
    newDetail.detailNew = _detailModel;
    
    [self.navigationController pushViewController:newDetail animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)viewWillAppear:(BOOL)animated{
    
    
    [self.tabBarController.tabBar setHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
    
    
    [self.tabBarController.tabBar setHidden:NO];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
